//
//  YKClientNeedsDetailViewController.m
//  YunKang
//
//  Created by leoking870 on 2017/10/3.
//  Copyright © 2017年 leoking870. All rights reserved.
//

#import "YKClientNeedsDetailViewController.h"
#import "YKClientNeedsHeaderView.h"
#import "YKInputView.h"
#import "YKInputMultilineView.h"
#import "YKClientNeedsDetailModel.h"
@interface YKClientNeedsDetailViewController ()
@property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) YKClientNeedsDetailModel *mYKClientNeedsDetailModel;
@end

@implementation YKClientNeedsDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title = @"需求详情";
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    [self tf_showStateView:kTFViewStateLoading];
    [TFHTTPMANAER POST:@"personalCentr/searchCustomerDemandById.htm" parameters:@{@"id":self.m_id} success:^(id responseObject) {
        self.mYKClientNeedsDetailModel = [YKClientNeedsDetailModel yy_modelWithJSON:responseObject[@"customerDemand"]];
        [self tf_showStateView:kTFViewStateNone];
        [self updateViews];
    } failure:^(id responseObject, NSError *error) {
        [self tf_showStateView:kTFViewStateNetError];
    }];
    
    
    
}

- (void)updateViews {
    YKClientNeedsHeaderView *headerView = [[[NSBundle mainBundle]loadNibNamed:@"YKClientNeedsHeaderView" owner:self options:nil]firstObject];
    headerView.model = self.mYKClientNeedsDetailModel;
    [self.view addSubview:headerView];
    [headerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.top.trailing.equalTo(self.view);
    }];
    
    self.scrollView = [[UIScrollView alloc]init];
    [self.view addSubview:self.scrollView];
    [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.bottom.trailing.equalTo(self.view);
        make.top.equalTo(headerView.mas_bottom);
    }];
    
    
    YKInputView* drugNameView = [[YKInputView alloc]initWithTitle:@"通用名" input:self.mYKClientNeedsDetailModel.DRUGSNAME];
    [self.scrollView addSubview:drugNameView];
    drugNameView.editable = NO;
    YKInputView* drugCodeView = [[YKInputView alloc]initWithTitle:@"药品规格" input:self.mYKClientNeedsDetailModel.DRUGSSPEC];
    drugCodeView.editable = NO;
    [self.scrollView addSubview:drugCodeView];
    
    YKInputView* manufactoryView = [[YKInputView alloc]initWithTitle:@"生产厂家" input:self.mYKClientNeedsDetailModel.MANUFACTURER];
    manufactoryView.editable = NO;
    [self.scrollView addSubview:manufactoryView];
    
    
    YKInputView* needNumberView = [[YKInputView alloc]initWithTitle:@"需求数量" input:self.mYKClientNeedsDetailModel.DEMANDNUMBER];
    needNumberView.editable = NO;
    [self.scrollView addSubview:needNumberView];
    
    YKInputView* channelView = [[YKInputView alloc]initWithTitle:@"货源渠道" input:self.mYKClientNeedsDetailModel.SUPPLYCHANNEL];
    channelView.editable = NO;
    [self.scrollView addSubview:channelView];
    
    YKInputView* approveCodeView = [[YKInputView alloc]initWithTitle:@"批准文号" input:self.mYKClientNeedsDetailModel.GRANTNO];
    approveCodeView.editable = NO;
    [self.scrollView addSubview:approveCodeView];
    
    
    YKInputMultilineView *clientNoteView = [[YKInputMultilineView alloc]initWithTitle:@"客户留言" input:self.mYKClientNeedsDetailModel.REMARK];
    clientNoteView.editable = NO;
    [self.scrollView addSubview:clientNoteView];
    
    YKInputView* uploadView = [[YKInputView alloc]initWithTitle:@"上传附件" input:@""];
    uploadView.inputBackgroundColor = [UIColor clearColor];
    uploadView.inputTextColor = [UIColor tf_colorWithHexString:@"#8ec21f"];
    uploadView.editable = NO;
    uploadView.inputTextFont = [UIFont systemFontOfSize:14];
    [self.scrollView addSubview:uploadView];
    
    [self.scrollView.subviews mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.equalTo(self.scrollView);
        make.width.mas_equalTo(self.scrollView.mas_width);
    }];
    
    [self.scrollView.subviews mas_alignAlongAxis:MASAxisTypeVertical fixedSpace:@0 leadSpace:8 tailSpace:8];
}

@end
